package load.drawing;

import core.InPort;
import core.StdNode;
import core.TriggerPort;
import java.awt.Color;
import java.awt.Graphics;

/**
 *
 * @author Ben
 */
public class DrawRoundRect  extends StdNode{
    private InPort x = new InPort(Integer.class);
    private InPort y = new InPort(Integer.class);
    private InPort width = new InPort(Integer.class);
    private InPort height = new InPort(Integer.class);
    private InPort arcWidth = new InPort(Integer.class);
    private InPort arcHeight = new InPort(Integer.class);
    private InPort color = new InPort(Color.class);

    private TriggerPort draw = new TriggerPort() {
            @Override
            public void callInternal() {
                Graphics g = controller.StdDraw.getInstance().getGraphics();
                g.setColor((Color)color.getValue());
                g.drawRoundRect((Integer)x.getValue(),(Integer) y.getValue(),
                     (Integer)width.getValue(), (Integer)height.getValue(),
                     (Integer)arcWidth.getValue(), (Integer)arcHeight.getValue());
            }
    };

    private TriggerPort fill = new TriggerPort() {
            @Override
            public void callInternal() {
                Graphics g = controller.StdDraw.getInstance().getGraphics();
                g.fillRoundRect((Integer)x.getValue(),(Integer) y.getValue(),
                     (Integer)width.getValue(), (Integer)height.getValue(),
                     (Integer)arcWidth.getValue(), (Integer)arcHeight.getValue());
            }
    };

    public DrawRoundRect() {
        this.autoPutPorts();
    }

}
